package com.itheima.clone;

/**
 * @program: itheima-jdk8
 * @description:
 * @author: zhanghz001
 * @create: 2021-01-10 11:40
 **/
public class Student1 implements Cloneable {
    
    private String name;
    
    private int age;
    
    private Person person;
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public int getAge() {
        return age;
    }
    
    public void setAge(int age) {
        this.age = age;
    }
    
    public Person getPerson() {
        return person;
    }
    
    public void setPerson(Person person) {
        this.person = person;
    }
    
    @Override
    public String toString() {
        return "Student{" +
                this.hashCode() +
                "name='" + name + '\'' +
                ", age=" + age +
                ", person=" + person +
                '}';
    }
    
    @Override
    public Object clone() {
        try {
            Student1 student1 = (Student1) super.clone();
            student1.person = (Person) person.clone();
            return student1;
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }
}
